<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="../../res/layui/css/layui.css" media="all">
    <script src="../../res/js/jquery-3.1.1.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../res/layui/layui.js" charset="utf-8"></script>
    <script src="../../res/js/Tools.js" type="text/javascript"></script>
</head>
<style>
    body {
        min-width: 320px;
        max-width: 99%;
        margin: 0 auto;
        color: #333;
        padding: 0;
        font-family: "Microsoft Yahei";
        text-align: center;
    }

    .title_font {
        font-weight: bold;
        color:#000;
    }

    .zbs{
        overflow: hidden;
        padding: 10px;
        padding-left: 50px;
        padding-right: 50px;

    }
</style>
<body>
<table class="layui-table" lay-even="" lay-skin="nob">
    <tbody>
    <tr>
        <td class="title_font">计划名称</td>
        <td id="curriculumName"></td>
        <td class="title_font">运动项目名称</td>
        <td id="itemName"></td>
        <td class="title_font">教练员姓名</td>
        <td id="coachName"></td>
    </tr>
    <tr>
        <td class="title_font">应到人数</td>
        <td id="weekShould"></td>
        <td class="title_font">实到人数</td>
        <td id="weekReality"></td>
        <td class="title_font">制定时间</td>
        <td id="planDate"></td>
    </tr>
    <tr>
        <td class="title_font">运动负荷</td>
        <td id="weekLoad"></td>
        <td class="title_font">运动强度</td>
        <td id="curIntensity"></td>
        <td class="title_font">运动量</td>
        <td id="curScale"></td>
    </tr>
    </tbody>
</table>
<label class="layui-form-label">训练课任务</label>
<div class="layui-input-block">
    <textarea placeholder="请输入内容" id="weekTask" style="margin-bottom: 10px" class="layui-textarea"
              disabled=""></textarea>
</div>
<div class="layui-form-item">
    <div class="overZhiBiao"></div>
</div>


</body>

<script>
    $.ajaxSetup({
        async: false
    });



    $(function () {
        var id = getQueryString("curriculumId");
        //表
        var url = "../../atsCurriculumController/findById";
        var data = {curriculumId: id}
        $.post(url, data, function (obj) {
            $("#curriculumName").text(obj.data.curriculumName);//计划名称
            $("#itemName").text(obj.data.itemName);//运动项目名称

            $("#coachName").text(obj.data.coachName);//教练员姓名
            $("#planDate").text(obj.data.planDate);//制定时间
            $("#weekShould").text(obj.data.weekShould);//应到人数
            $("#weekReality").text(obj.data.weekReality);//实到人数
            $("#weekLoad").text(obj.data.weekLoad);//运动负荷
            $("#curIntensity").text(obj.data.curIntensity);//运动强度
            $("#curScale").text(obj.data.curScale);//运动量
            $("#weekTask").text(obj.data.weekTask);//训练任务
        }, "json");

        var url ="../../atsBaseItem/findPlanItem";
        var data={pid:id};
        console.info(id+"===================")
        $.post(url,data,function(obj){

            $.each(obj ,function (index,item) {
                console.info(item)
                if(!$("#zb"+item.id).length>0){
                    console.info(item)
                    atsDatas(item)
                }
            })
        },'json')

        var url ="../../atsBaseItem/findPlan";
        var data={pid:id};
        console.info(id+"===================")
        $.post(url,data,function(obj){
            $.each(obj ,function (index,item) {
                console.info("#zb_"+item.id+"_"+item.field)
                $("#zhiBiao_"+item.id+"_"+item.field).val(item.label);
            })
        },'json')
    })
var overZhiBiao="";
    /**
     * 打印树状表单html（无限级）
     **/
    function atsDatas(atsData) {

        console.info(atsData.children+"-----")
        console.info(atsData.children)

        overZhiBiao += "<div style='clear:both'></div><fieldset class='layui-elem-field layui-field-title zb' style='margin-top: 20px;' id='zb" + atsData.id + "'><legend>"+atsData.name+"：【" + atsData.label + "】</legend></fieldset>";
        overZhiBiao += "<div id='zbs" + atsData.id + "' class='zbs'>";
        overZhiBiao += zhiBiaos(atsData.id);
        //overZhiBiao += "<div class='values' style='float: left;'><div class='layui-form-item'><label class='layui-form-label'>" + item.name + "</label><div class='layui-input-block'><input type='text' id='zhiBiao_" + item.id + "' name='zhiBiao_" + item.id + "' autocomplete='off' placeholder='" + item.title + "' class='layui-input loginPaDuan'></div></div></div>";
        overZhiBiao += "</div>";

        $(".overZhiBiao").append(overZhiBiao);
        overZhiBiao="";
    }

    function zhiBiaos(topId) {
        var zhiBiao="";
        var url="../../dicAction/selectType";
        var data={dcode:"PLAN"};
        $.post(url,data,function (obj) {
            $.each(obj,function (index,item) {
                zhiBiao+="<div class='values' style='float: left;'><div class='layui-form-item' style='margin-left: 10px;text-align: center'>" + item.dname + "<div style='width: 80px'><input type='text' id='zhiBiao_"+topId+"_" + item.did + "' name='zhiBiao'  disabled placeholder='"+item.dtype+"' autocomplete='off' class='layui-input loginPaDuan'></div></div></div>"
            })
        })

        return zhiBiao;
    }
</script>

</html>